﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinForm
{
    public partial class DonHangForm : Form
    {
        private List<Library.BIZ.HoaDonXuatBIZ> hoadon;
        private bool f = false;

        public DonHangForm()
        {
            InitializeComponent();

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.MultiSelect = false;
        }

        private void DonHang_Load(object sender, EventArgs e)
        {
            comboBox1.SelectedIndex = 0;
            
            hoadon = Library.DAL.HoaDonXuatDAL.FindAll(0);

            dataGridView1.DataSource = hoadon;
            
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            hoadon = Library.DAL.HoaDonXuatDAL.FindAll(comboBox1.SelectedIndex);
            dataGridView1.DataSource = hoadon;
        }

        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            f = true;
            try
            {
                Library.BIZ.HoaDonXuatBIZ h = (Library.BIZ.HoaDonXuatBIZ)dataGridView1.CurrentRow.DataBoundItem;

                new ChiTietDonHangForm(h).Show();
            }
            catch
            {
            }

        }

        private void DonHangForm_Activated(object sender, EventArgs e)
        {
            if (f)
            {
                hoadon = Library.DAL.HoaDonXuatDAL.FindAll(comboBox1.SelectedIndex);
                dataGridView1.DataSource = hoadon;
                f = false;
            }
        }

    }
}
